import api
import env
import mcrud
import ampractice
import amauth
import amuserdetail
import amstudent
import amcountdown
import upload
import amfile

env.load(".env")
db = mcrud.new_env()
save_dir = "uploads"

app = api.Api(
    routes=[
        *ampractice.get_routes(db),
        *amauth.get_all_routers(db),
        *amuserdetail.get_routes(db),
        *amstudent.get_routes(db),
        *amcountdown.get_routes_num(db),
        upload.download("/download/{filename}", save_dir),
        upload.upload("/upload", save_dir),
        *amfile.get_routes(db),
    ],
    middleware=[api.middleware.cors()]
)

if __name__ == "__main__":
    app.run(port=8889)
